#ifndef MODULES_WIFI_WIFISERVICE_H_
#define MODULES_WIFI_WIFISERVICE_H_
#include "../core/IBean.h"
#include <Wifi.h>

class WifiConfig: public IEntity {
public:
	WifiConfig(std::string ssid, std::string passwd) :
					ssid(ssid), passwd(passwd) {
	}
	std::string ssid;
	std::string passwd;
	int errorTimes;

	void save(std::string ssid, std::string password) {
		this->ssid = ssid;
		this->passwd = password;
		this->errorTimes = 0;
	}
	void clear() {
		this->ssid.clear();
		this->passwd.clear();
		this->errorTimes = 0;
	}
	bool isEmpty() {
		return ssid.empty() || passwd.empty();
	}
	bool check(std::string ssid, std::string password) {
		return this->ssid == ssid && this->passwd == password;
	}

	ENTITY_INJECTION_ID_AND_REPOSITORY("wifiConfig")
 	AIGC_JSON_HELPER(id,ssid, passwd,errorTimes)
};

class WifiService: public IBean {
private :
	 tm timeinfo;
public:
	void restart();
	bool smartConfig();
	void syncSystemTime();
	void prepare();
	bool isConnected();
};

#endif /* MODULES_WIFI_WIFISERVICE_H_ */
